a11y tests: Use the new AtkValue interface
authorMatthias Clasen <mclasen@redhat.com>
Sat, 3 May 2014 00:48:35 +0000 (20:48 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 3 May 2014 00:52:56 +0000 (20:52 -0400)
The old interface is deprecated, and we just implemented the
new one, so lets test it.

testsuite/a11y/accessibility-dump.c
testsuite/a11y/value.c

index 2b58ca82648552ba66e92142b49b75d0aff28dad..80b62c2a0d5c3606b5c4a13fd23b0538c2f8ad3f 100644 (file)
@@ -427,40 +427,34 @@ dump_atk_value (AtkValue *atk_value,
                 guint     depth,
                 GString  *string)
 {
-  GValue value = G_VALUE_INIT;
-  GValue svalue = G_VALUE_INIT;
+  AtkRange *range;
+  gdouble value;
+  gchar *text;
 
-  g_string_append_printf (string, "%*s<AtkValue>\n", depth, "");
+  value = 0.0;
+  text = NULL;
 
-  g_value_init (&value, G_TYPE_DOUBLE);
-  g_value_init (&svalue, G_TYPE_STRING);
+  atk_value_get_value_and_text (atk_value, &value, &text);
+  range = atk_value_get_range (atk_value);
 
-  atk_value_get_minimum_value (atk_value, &value);
-  if (g_value_transform (&value, &svalue))
-    g_string_append_printf (string, "%*sminimum value: %s\n", depth, "", g_value_get_string (&svalue));
-  else
-    g_string_append_printf (string, "%*sminimum value: <%s>\n", depth, "", G_VALUE_TYPE_NAME (&value));
+  g_string_append_printf (string, "%*s<AtkValue>\n", depth, "");
 
-  g_value_reset (&value);
-  g_value_reset (&svalue);
+  if (range)
+    {
+      g_string_append_printf (string, "%*sminimum value: %f\n", depth, "", atk_range_get_lower_limit (range));
 
-  atk_value_get_maximum_value (atk_value, &value);
-  if (g_value_transform (&value, &svalue))
-    g_string_append_printf (string, "%*smaximum value: %s\n", depth, "", g_value_get_string (&svalue));
-  else
-    g_string_append_printf (string, "%*smaximum value: <%s>\n", depth, "", G_VALUE_TYPE_NAME (&value));
+      g_string_append_printf (string, "%*smaximum value: %f\n", depth, "", atk_range_get_upper_limit (range));
 
-  g_value_reset (&value);
-  g_value_reset (&svalue);
+      atk_range_free (range);
+    }
 
-  atk_value_get_current_value (atk_value, &value);
-  if (g_value_transform (&value, &svalue))
-    g_string_append_printf (string, "%*scurrent value: %s\n", depth, "", g_value_get_string (&svalue));
+  if (text)
+    {
+      g_string_append_printf (string, "%*scurrent value: %f %s\n", depth, "", value, text); 
+      g_free (text);
+    }
   else
-    g_string_append_printf (string, "%*scurrent value: %s\n", depth, "", G_VALUE_TYPE_NAME (&value));
-
-  g_value_reset (&value);
-  g_value_reset (&svalue);
+    g_string_append_printf (string, "%*scurrent value: %f\n", depth, "", value);
 
   /* Don't dump minimum increment; it changes too much in response to
    * theme changes.
index af50a3688ec8c9530232610b153bfedd2e86e096..909c8e8d3ef011b4dc1310ce5e73dc7cf46ad306 100644 (file)
@@ -63,7 +63,8 @@ test_basic (GtkWidget *widget)
   AtkObject *atk_object;
   AtkValue *atk_value;
   gdouble value = 50;
-  GValue ret;
+  gdouble ret;
+  gchar *text;
 
   atk_object = gtk_widget_get_accessible (widget);
   atk_value = ATK_VALUE (atk_object);
@@ -74,9 +75,10 @@ test_basic (GtkWidget *widget)
   g_assert_cmpint (notify_data.count, ==, 1);
   g_assert_cmpstr (notify_data.last_name, ==, "accessible-value");
 
-  memset (&ret, 0, sizeof (ret));
-  atk_value_get_current_value (atk_value, &ret);
-  g_assert_cmpfloat (g_value_get_double (&ret), ==, value);
+  text = NULL;
+  atk_value_get_value_and_text (atk_value, &ret, &text);
+  g_assert_cmpfloat (ret, ==, value);
+  g_free (text);
 
   g_free (notify_data.last_name);
   g_signal_handlers_disconnect_by_func (atk_object, G_CALLBACK (notify_cb), &notify_data);